package com.quanyan.runningriding.web.running;

import com.quanyan.api.APIResponse;
import com.quanyan.common.Plugin.PageObj;
import com.quanyan.runningriding.entity.vo.run.resp.MusicDetails;
import com.quanyan.runningriding.service.RunMusicDetailsService;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by liubin on 2016/12/15.
 * 音乐歌单详情
 */

    @RestController
    @RequestMapping(value = "/api/run")
    public class RunMusicDetailsController {
        @Autowired
        RunMusicDetailsService runMusicDetailsService;
        private Logger logger = LoggerFactory.getLogger(RunMusicDetailsController.class);

        @RequestMapping(value = "/musicDetailsList", method = RequestMethod.POST)
        public APIResponse<MusicDetails> musicDetailsList(@RequestBody Map<String,Object> paramMap){
            Integer musicCollectionId = MapUtils.getInteger(paramMap, "musicCollectionId");
            String userId = MapUtils.getString(paramMap, "userId");
            if (musicCollectionId == null) {
                return APIResponse.returnFail("歌单id不能为空");
            }
            if (userId == null || "".equals(userId)) {
                return APIResponse.returnFail("用户id不能为空");
            }
            APIResponse<MusicDetails> result = runMusicDetailsService.musicDetailsList(paramMap);
            return result;
        }
    }
